* Economic Risk within the Household and Voting for the Radical Right
* Tarik Abou-Chadi and Thomas Kurer
* World Politics

** REPLICATION FILES

* Part 2: Merge ESS and EU-SILC data
* Preparation (lines start - 1094)
* Merging (lines 1094-end)

* PREPARATION

clear
file close _all
macro drop _all

set more off

* set paths (needs to be adjusted before running script)
global path "..."
global final "..."
global datpath "..."


* LOAD CUMULATIVE ESS 1-8

use "$path/ess1-8_data_party.dta"

* CREATE VARIABLES NEEDED FOR MERGING

* Generate Oesch classes
* Code from Daniel Oesch: https://people.unil.ch/danieloesch/scripts/

****************************************************************************************
* Respondent's Oesch class position
* Recode and create variables used to construct class variable for respondents
* Variables used to construct class variable for respondents: iscoco, emplrel, emplno
****************************************************************************************

**** Recode occupation variable (isco88 com 4-digit) for respondents

tab iscoco

recode iscoco (66666 77777 88888 99999=-9), copyrest gen(isco_mainjob88)
label variable isco_mainjob88 "Current occupation of respondent - isco88 4-digit"
tab isco_mainjob88

**** Recode occupation variable (isco08 com 4-digit) for respondents

tab isco08

recode isco08 (missing=-9), copyrest gen(isco_mainjob08)
label variable isco_mainjob08 "Current occupation of respondent - isco88 4-digit"
tab isco_mainjob08

**** Recode employment status for respondents

tab emplrel 

recode emplrel (missing=9), copyrest gen(emplrel_r)
label define emplrel_r ///
1 "Employee" ///
2 "Self-employed" ///
3 "Working for own family business" ///
9 "Missing"
label value emplrel_r emplrel_r
tab emplrel_r

tab emplno

recode emplno (0=0)(1/9=1)(10/10000=2)(missing=0), gen(emplno_r)
label define emplno_r ///
0 "0 employees" ///
1 "1-9 employees" ///
2 "10+ employees"
label value emplno_r emplno_r
tab emplno_r

gen selfem_mainjob=.
replace selfem_mainjob=1 if emplrel_r==1 | emplrel_r==9
replace selfem_mainjob=2 if emplrel_r==2 & emplno_r==0
replace selfem_mainjob=2 if emplrel_r==3
replace selfem_mainjob=3 if emplrel_r==2 & emplno_r==1
replace selfem_mainjob=4 if emplrel_r==2 & emplno_r==2
label variable selfem_mainjob "Employment status for respondants"
label define selfem_mainjob ///
1 "Not self-employed" ///
2 "Self-empl without employees" ///
3 "Self-empl with 1-9 employees" ///
4 "Self-empl with 10 or more"
label value selfem_mainjob selfem_mainjob
tab selfem_mainjob


*************************************************
* Create Oesch class schema for respondents
*************************************************

gen class16_r = -9.

* Large employers (1)

replace class16_r=1 if selfem_mainjob==4

* ISCO 88



* Self-employed professionals (2)

replace class16_r=2 if (selfem_mainjob==2 | selfem_mainjob==3) & (isco_mainjob88 >= 2000 & isco_mainjob88 <= 2229) 
replace class16_r=2 if (selfem_mainjob==2 | selfem_mainjob==3) & (isco_mainjob88 >= 2300 & isco_mainjob88 <= 2470)

* Small business owners with employees (3)

replace class16_r=3 if (selfem_mainjob==3) & (isco_mainjob88 >= 1000 & isco_mainjob88 <= 1999)
replace class16_r=3 if (selfem_mainjob==3) & (isco_mainjob88 >= 3000 & isco_mainjob88 <= 9333)
replace class16_r=3 if (selfem_mainjob==3) & (isco_mainjob88 == 2230)

* Small business owners without employees (4)

replace class16_r=4 if (selfem_mainjob==2) & (isco_mainjob88 >= 1000 & isco_mainjob88 <= 1999)
replace class16_r=4 if (selfem_mainjob==2) & (isco_mainjob88 >= 3000 & isco_mainjob88 <= 9333)
replace class16_r=4 if (selfem_mainjob==2) & (isco_mainjob88 == 2230)

* Technical experts (5)

replace class16_r=5 if (selfem_mainjob==1) & (isco_mainjob88 >= 2100 & isco_mainjob88 <= 2213)

* Technicians (6)

replace class16_r=6 if (selfem_mainjob==1) & (isco_mainjob88 >= 3100 & isco_mainjob88 <= 3152)
replace class16_r=6 if (selfem_mainjob==1) & (isco_mainjob88 >= 3210 & isco_mainjob88 <= 3213)
replace class16_r=6 if (selfem_mainjob==1) & (isco_mainjob88 == 3434)

* Skilled manual (7)

replace class16_r=7 if (selfem_mainjob==1) & (isco_mainjob88 >= 6000 & isco_mainjob88 <= 7442)
replace class16_r=7 if (selfem_mainjob==1) & (isco_mainjob88 >= 8310 & isco_mainjob88 <= 8312)
replace class16_r=7 if (selfem_mainjob==1) & (isco_mainjob88 >= 8324 & isco_mainjob88 <= 8330)
replace class16_r=7 if (selfem_mainjob==1) & (isco_mainjob88 >= 8332 & isco_mainjob88 <= 8340)

* Low-skilled manual (8)

replace class16_r=8 if (selfem_mainjob==1) & (isco_mainjob88 >= 8000 & isco_mainjob88 <= 8300)
replace class16_r=8 if (selfem_mainjob==1) & (isco_mainjob88 >= 8320 & isco_mainjob88 <= 8321)
replace class16_r=8 if (selfem_mainjob==1) & (isco_mainjob88 == 8331)
replace class16_r=8 if (selfem_mainjob==1) & (isco_mainjob88 >= 9153 & isco_mainjob88 <= 9333)

* Higher-grade managers and administrators (9)

replace class16_r=9 if (selfem_mainjob==1) & (isco_mainjob88 >= 1000 & isco_mainjob88 <= 1239)
replace class16_r=9 if (selfem_mainjob==1) & (isco_mainjob88 >= 2400 & isco_mainjob88 <= 2429)
replace class16_r=9 if (selfem_mainjob==1) & (isco_mainjob88 == 2441)
replace class16_r=9 if (selfem_mainjob==1) & (isco_mainjob88 == 2470)

* Lower-grade managers and administrators (10)

replace class16_r=10 if (selfem_mainjob==1) & (isco_mainjob88 >= 1300 & isco_mainjob88 <= 1319)
replace class16_r=10 if (selfem_mainjob==1) & (isco_mainjob88 >= 3400 & isco_mainjob88 <= 3433)
replace class16_r=10 if (selfem_mainjob==1) & (isco_mainjob88 >= 3440 & isco_mainjob88 <= 3450)

* Skilled clerks (11)

replace class16_r=11 if (selfem_mainjob==1) & (isco_mainjob88 >= 4000 & isco_mainjob88 <= 4112)
replace class16_r=11 if (selfem_mainjob==1) & (isco_mainjob88 >= 4114 & isco_mainjob88 <= 4210)
replace class16_r=11 if (selfem_mainjob==1) & (isco_mainjob88 >= 4212 & isco_mainjob88 <= 4222)

* Unskilled clerks (12)

replace class16_r=12 if (selfem_mainjob==1) & (isco_mainjob88 == 4113)
replace class16_r=12 if (selfem_mainjob==1) & (isco_mainjob88 == 4211)
replace class16_r=12 if (selfem_mainjob==1) & (isco_mainjob88 == 4223)

* Socio-cultural professionals (13)

replace class16_r=13 if (selfem_mainjob==1) & (isco_mainjob88 >= 2220 &  isco_mainjob88 <= 2229)
replace class16_r=13 if (selfem_mainjob==1) & (isco_mainjob88 >= 2300 &  isco_mainjob88 <= 2320)
replace class16_r=13 if (selfem_mainjob==1) & (isco_mainjob88 >= 2340 &  isco_mainjob88 <= 2359)
replace class16_r=13 if (selfem_mainjob==1) & (isco_mainjob88 >= 2430 &  isco_mainjob88 <= 2440)
replace class16_r=13 if (selfem_mainjob==1) & (isco_mainjob88 >= 2442 &  isco_mainjob88 <= 2443)
replace class16_r=13 if (selfem_mainjob==1) & (isco_mainjob88 == 2445)
replace class16_r=13 if (selfem_mainjob==1) & (isco_mainjob88 == 2451)
replace class16_r=13 if (selfem_mainjob==1) & (isco_mainjob88 == 2460)

* Socio-cultural semi-professionals (14)

replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob88 == 2230)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob88 >= 2330 & isco_mainjob88 <= 2332)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob88 == 2444)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob88 >= 2446 & isco_mainjob88 <= 2450)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob88 >= 2452 & isco_mainjob88 <= 2455)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob88 == 3200)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob88 >= 3220 & isco_mainjob88 <= 3224)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob88 == 3226)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob88 >= 3229 & isco_mainjob88 <= 3340)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob88 >= 3460 & isco_mainjob88 <= 3472)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob88 == 3480)

* Skilled service (15)

replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob88 == 3225)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob88 >= 3227 & isco_mainjob88 <= 3228)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob88 >= 3473 & isco_mainjob88 <= 3475)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob88 >= 5000 & isco_mainjob88 <= 5113)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob88 == 5122)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob88 >= 5131 & isco_mainjob88 <= 5132)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob88 >= 5140 & isco_mainjob88 <= 5141)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob88 == 5143)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob88 >= 5160 & isco_mainjob88 <= 5220)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob88 == 8323)

* Low-skilled service (16)

replace class16_r=16 if (selfem_mainjob==1) & (isco_mainjob88 >= 5120 & isco_mainjob88 <= 5121)
replace class16_r=16 if (selfem_mainjob==1) & (isco_mainjob88 >= 5123 & isco_mainjob88 <= 5130)
replace class16_r=16 if (selfem_mainjob==1) & (isco_mainjob88 >= 5133 & isco_mainjob88 <= 5139)
replace class16_r=16 if (selfem_mainjob==1) & (isco_mainjob88 == 5142)
replace class16_r=16 if (selfem_mainjob==1) & (isco_mainjob88 == 5149)
replace class16_r=16 if (selfem_mainjob==1) & (isco_mainjob88 == 5230)
replace class16_r=16 if (selfem_mainjob==1) & (isco_mainjob88 == 8322)
replace class16_r=16 if (selfem_mainjob==1) & (isco_mainjob88 >= 9100 &  isco_mainjob88 <= 9152)

* Self-employed professionals (2)

replace class16_r=2 if (selfem_mainjob==2 | selfem_mainjob==3) & (isco_mainjob08 >= 2000 & isco_mainjob08 <= 2162) 
replace class16_r=2 if (selfem_mainjob==2 | selfem_mainjob==3) & (isco_mainjob08 >= 2164 & isco_mainjob08 <= 2165) 
replace class16_r=2 if (selfem_mainjob==2 | selfem_mainjob==3) & (isco_mainjob08 >= 2200 & isco_mainjob08 <= 2212) 
replace class16_r=2 if (selfem_mainjob==2 | selfem_mainjob==3) & (isco_mainjob08 == 2250)
replace class16_r=2 if (selfem_mainjob==2 | selfem_mainjob==3) & (isco_mainjob08 >= 2261 & isco_mainjob08 <= 2262)
replace class16_r=2 if (selfem_mainjob==2 | selfem_mainjob==3) & (isco_mainjob08 >= 2300 & isco_mainjob08 <= 2330)
replace class16_r=2 if (selfem_mainjob==2 | selfem_mainjob==3) & (isco_mainjob08 >= 2350 & isco_mainjob08 <= 2352)
replace class16_r=2 if (selfem_mainjob==2 | selfem_mainjob==3) & (isco_mainjob08 >= 2359 & isco_mainjob08 <= 2432)
replace class16_r=2 if (selfem_mainjob==2 | selfem_mainjob==3) & (isco_mainjob08 >= 2500 & isco_mainjob08 <= 2619)
replace class16_r=2 if (selfem_mainjob==2 | selfem_mainjob==3) & (isco_mainjob08 == 2621)
replace class16_r=2 if (selfem_mainjob==2 | selfem_mainjob==3) & (isco_mainjob08 >= 2630 & isco_mainjob08 <= 2634)
replace class16_r=2 if (selfem_mainjob==2 | selfem_mainjob==3) & (isco_mainjob08 >= 2636 & isco_mainjob08 <= 2640)
replace class16_r=2 if (selfem_mainjob==2 | selfem_mainjob==3) & (isco_mainjob08 >= 2642 & isco_mainjob08 <= 2643)

* Small business owners with employees (3)

replace class16_r=3 if (selfem_mainjob==3) & (isco_mainjob08 >= 1000 & isco_mainjob08 <= 1439)
replace class16_r=3 if (selfem_mainjob==3) & (isco_mainjob08 == 2163)
replace class16_r=3 if (selfem_mainjob==3) & (isco_mainjob08 == 2166)
replace class16_r=3 if (selfem_mainjob==3) & (isco_mainjob08 >= 2220 & isco_mainjob08 <= 2240)
replace class16_r=3 if (selfem_mainjob==3) & (isco_mainjob08 == 2260)
replace class16_r=3 if (selfem_mainjob==3) & (isco_mainjob08 >= 2263 & isco_mainjob08 <= 2269)
replace class16_r=3 if (selfem_mainjob==3) & (isco_mainjob08 >= 2340 & isco_mainjob08 <= 2342)
replace class16_r=3 if (selfem_mainjob==3) & (isco_mainjob08 >= 2353 & isco_mainjob08 <= 2356)
replace class16_r=3 if (selfem_mainjob==3) & (isco_mainjob08 >= 2433 & isco_mainjob08 <= 2434)
replace class16_r=3 if (selfem_mainjob==3) & (isco_mainjob08 == 2620)
replace class16_r=3 if (selfem_mainjob==3) & (isco_mainjob08 == 2622)
replace class16_r=3 if (selfem_mainjob==3) & (isco_mainjob08 == 2635)
replace class16_r=3 if (selfem_mainjob==3) & (isco_mainjob08 == 2641)
replace class16_r=3 if (selfem_mainjob==3) & (isco_mainjob08 >= 2650 & isco_mainjob08 <= 2659)
replace class16_r=3 if (selfem_mainjob==3) & (isco_mainjob08 >= 3000 & isco_mainjob08 <= 9629)

* Small business owners without employees (4)

replace class16_r=4 if (selfem_mainjob==2) & (isco_mainjob08 >= 1000 & isco_mainjob08 <= 1439)
replace class16_r=4 if (selfem_mainjob==2) & (isco_mainjob08 == 2163)
replace class16_r=4 if (selfem_mainjob==2) & (isco_mainjob08 == 2166)
replace class16_r=4 if (selfem_mainjob==2) & (isco_mainjob08 >= 2220 & isco_mainjob08 <= 2240)
replace class16_r=4 if (selfem_mainjob==2) & (isco_mainjob08 == 2260)
replace class16_r=4 if (selfem_mainjob==2) & (isco_mainjob08 >= 2263 & isco_mainjob08 <= 2269)
replace class16_r=4 if (selfem_mainjob==2) & (isco_mainjob08 >= 2340 & isco_mainjob08 <= 2342)
replace class16_r=4 if (selfem_mainjob==2) & (isco_mainjob08 >= 2353 & isco_mainjob08 <= 2356)
replace class16_r=4 if (selfem_mainjob==2) & (isco_mainjob08 >= 2433 & isco_mainjob08 <= 2434)
replace class16_r=4 if (selfem_mainjob==2) & (isco_mainjob08 == 2620)
replace class16_r=4 if (selfem_mainjob==2) & (isco_mainjob08 == 2622)
replace class16_r=4 if (selfem_mainjob==2) & (isco_mainjob08 == 2635)
replace class16_r=4 if (selfem_mainjob==2) & (isco_mainjob08 == 2641)
replace class16_r=4 if (selfem_mainjob==2) & (isco_mainjob08 >= 2650 & isco_mainjob08 <= 2659)
replace class16_r=4 if (selfem_mainjob==2) & (isco_mainjob08 >= 3000 & isco_mainjob08 <= 9629)

* Technical experts (5)

replace class16_r=5 if (selfem_mainjob==1) & (isco_mainjob08 >= 2100 & isco_mainjob08 <= 2162)
replace class16_r=5 if (selfem_mainjob==1) & (isco_mainjob08 >= 2164 & isco_mainjob08 <= 2165)
replace class16_r=5 if (selfem_mainjob==1) & (isco_mainjob08 >= 2500 & isco_mainjob08 <= 2529)

* Technicians (6)

replace class16_r=6 if (selfem_mainjob==1) & (isco_mainjob08 >= 3100 & isco_mainjob08 <= 3155)
replace class16_r=6 if (selfem_mainjob==1) & (isco_mainjob08 >= 3210 & isco_mainjob08 <= 3214)
replace class16_r=6 if (selfem_mainjob==1) & (isco_mainjob08 == 3252)
replace class16_r=6 if (selfem_mainjob==1) & (isco_mainjob08 >= 3500 & isco_mainjob08 <= 3522)

* Skilled manual (7)

replace class16_r=7 if (selfem_mainjob==1) & (isco_mainjob08 >= 6000 & isco_mainjob08 <= 7549)
replace class16_r=7 if (selfem_mainjob==1) & (isco_mainjob08 >= 8310 & isco_mainjob08 <= 8312)
replace class16_r=7 if (selfem_mainjob==1) & (isco_mainjob08 == 8330)
replace class16_r=7 if (selfem_mainjob==1) & (isco_mainjob08 >= 8332 & isco_mainjob08 <= 8340)
replace class16_r=7 if (selfem_mainjob==1) & (isco_mainjob08 >= 8342 & isco_mainjob08 <= 8344)

* Low-skilled manual (8)

replace class16_r=8 if (selfem_mainjob==1) & (isco_mainjob08 >= 8000 & isco_mainjob08 <= 8300)
replace class16_r=8 if (selfem_mainjob==1) & (isco_mainjob08 >= 8320 & isco_mainjob08 <= 8321)
replace class16_r=8 if (selfem_mainjob==1) & (isco_mainjob08 == 8341)
replace class16_r=8 if (selfem_mainjob==1) & (isco_mainjob08 == 8350)
replace class16_r=8 if (selfem_mainjob==1) & (isco_mainjob08 >= 9200 & isco_mainjob08 <= 9334)
replace class16_r=8 if (selfem_mainjob==1) & (isco_mainjob08 >= 9600 & isco_mainjob08 <= 9620)
replace class16_r=8 if (selfem_mainjob==1) & (isco_mainjob08 >= 9622 & isco_mainjob08 <= 9629)

* Higher-grade managers and administrators (9)

replace class16_r=9 if (selfem_mainjob==1) & (isco_mainjob08 >= 1000 & isco_mainjob08 <= 1300)
replace class16_r=9 if (selfem_mainjob==1) & (isco_mainjob08 >= 1320 & isco_mainjob08 <= 1349)
replace class16_r=9 if (selfem_mainjob==1) & (isco_mainjob08 >= 2400 & isco_mainjob08 <= 2432)
replace class16_r=9 if (selfem_mainjob==1) & (isco_mainjob08 >= 2610 & isco_mainjob08 <= 2619)
replace class16_r=9 if (selfem_mainjob==1) & (isco_mainjob08 == 2631)
replace class16_r=9 if (selfem_mainjob==1) & (isco_mainjob08 >= 100 & isco_mainjob08 <= 110)

* Lower-grade managers and administrators (10)

replace class16_r=10 if (selfem_mainjob==1) & (isco_mainjob08 >= 1310 & isco_mainjob08 <= 1312)
replace class16_r=10 if (selfem_mainjob==1) & (isco_mainjob08 >= 1400 & isco_mainjob08 <= 1439)
replace class16_r=10 if (selfem_mainjob==1) & (isco_mainjob08 >= 2433 & isco_mainjob08 <= 2434)
replace class16_r=10 if (selfem_mainjob==1) & (isco_mainjob08 >= 3300 & isco_mainjob08 <= 3339)
replace class16_r=10 if (selfem_mainjob==1) & (isco_mainjob08 == 3343)
replace class16_r=10 if (selfem_mainjob==1) & (isco_mainjob08 >= 3350 & isco_mainjob08 <= 3359)
replace class16_r=10 if (selfem_mainjob==1) & (isco_mainjob08 == 3411)
replace class16_r=10 if (selfem_mainjob==1) & (isco_mainjob08 == 5221)
replace class16_r=10 if (selfem_mainjob==1) & (isco_mainjob08 >= 200 & isco_mainjob08 <= 210)

* Skilled clerks (11)

replace class16_r=11 if (selfem_mainjob==1) & (isco_mainjob08 >= 3340 & isco_mainjob08 <= 3342)
replace class16_r=11 if (selfem_mainjob==1) & (isco_mainjob08 == 3344)
replace class16_r=11 if (selfem_mainjob==1) & (isco_mainjob08 >= 4000 & isco_mainjob08 <= 4131)
replace class16_r=11 if (selfem_mainjob==1) & (isco_mainjob08 >= 4200 & isco_mainjob08 <= 4221)
replace class16_r=11 if (selfem_mainjob==1) & (isco_mainjob08 >= 4224 & isco_mainjob08 <= 4413)
replace class16_r=11 if (selfem_mainjob==1) & (isco_mainjob08 >= 4415 & isco_mainjob08 <= 4419)

* Unskilled clerks (12)

replace class16_r=12 if (selfem_mainjob==1) & (isco_mainjob08 == 4132)
replace class16_r=12 if (selfem_mainjob==1) & (isco_mainjob08 == 4222)
replace class16_r=12 if (selfem_mainjob==1) & (isco_mainjob08 == 4223)
replace class16_r=12 if (selfem_mainjob==1) & (isco_mainjob08 == 5230)
replace class16_r=12 if (selfem_mainjob==1) & (isco_mainjob08 == 9621)

* Socio-cultural professionals (13)

replace class16_r=13 if (selfem_mainjob==1) & (isco_mainjob08 >= 2200 &  isco_mainjob08 <= 2212)
replace class16_r=13 if (selfem_mainjob==1) & (isco_mainjob08 == 2250)
replace class16_r=13 if (selfem_mainjob==1) & (isco_mainjob08 >= 2261 &  isco_mainjob08 <= 2262)
replace class16_r=13 if (selfem_mainjob==1) & (isco_mainjob08 >= 2300 &  isco_mainjob08 <= 2330)
replace class16_r=13 if (selfem_mainjob==1) & (isco_mainjob08 >= 2350 &  isco_mainjob08 <= 2352)
replace class16_r=13 if (selfem_mainjob==1) & (isco_mainjob08 == 2359)
replace class16_r=13 if (selfem_mainjob==1) & (isco_mainjob08 == 2600)
replace class16_r=13 if (selfem_mainjob==1) & (isco_mainjob08 == 2621)
replace class16_r=13 if (selfem_mainjob==1) & (isco_mainjob08 == 2630)
replace class16_r=13 if (selfem_mainjob==1) & (isco_mainjob08 >= 2632 &  isco_mainjob08 <= 2634)
replace class16_r=13 if (selfem_mainjob==1) & (isco_mainjob08 >= 2636 &  isco_mainjob08 <= 2640)
replace class16_r=13 if (selfem_mainjob==1) & (isco_mainjob08 >= 2642 &  isco_mainjob08 <= 2643)

* Socio-cultural semi-professionals (14)

replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob08 == 2163)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob08 == 2166)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob08 >= 2220 & isco_mainjob08 <= 2240)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob08 == 2260)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob08 >= 2263 & isco_mainjob08 <= 2269)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob08 >= 2340 & isco_mainjob08 <= 2342)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob08 >= 2353 & isco_mainjob08 <= 2356)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob08 == 2620)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob08 == 2622)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob08 == 2635)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob08 == 2641)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob08 >= 2650 & isco_mainjob08 <= 2659)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob08 == 3200)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob08 >= 3220 & isco_mainjob08 <= 3230)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob08 == 3250)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob08 >= 3253 & isco_mainjob08 <= 3257)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob08 == 3259)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob08 >= 3400 & isco_mainjob08 <= 3410)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob08 >= 3412 & isco_mainjob08 <= 3413)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob08 >= 3430 & isco_mainjob08 <= 3433)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob08 == 3435)
replace class16_r=14 if (selfem_mainjob==1) & (isco_mainjob08 == 4414)

* Skilled service (15)

replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob08 == 3240)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob08 == 3251)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob08 == 3258)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob08 >= 3420 & isco_mainjob08 <= 3423)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob08 == 3434)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob08 >= 5000 & isco_mainjob08 <= 5120)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob08 >= 5140 & isco_mainjob08 <= 5142)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob08 == 5163)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob08 == 5165)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob08 == 5200)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob08 == 5220)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob08 >= 5222 & isco_mainjob08 <= 5223)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob08 >= 5241 & isco_mainjob08 <= 5242)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob08 >= 5300 & isco_mainjob08 <= 5321)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob08 >= 5400 & isco_mainjob08 <= 5413)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob08 == 5419)
replace class16_r=15 if (selfem_mainjob==1) & (isco_mainjob08 == 8331)

* Low-skilled service (16)

replace class16_r=16 if (selfem_mainjob==1) & (isco_mainjob08 >= 5130 & isco_mainjob08 <= 5132)
replace class16_r=16 if (selfem_mainjob==1) & (isco_mainjob08 >= 5150 & isco_mainjob08 <= 5162)
replace class16_r=16 if (selfem_mainjob==1) & (isco_mainjob08 == 5164)
replace class16_r=16 if (selfem_mainjob==1) & (isco_mainjob08 == 5169)
replace class16_r=16 if (selfem_mainjob==1) & (isco_mainjob08 >= 5210 & isco_mainjob08 <= 5212)
replace class16_r=16 if (selfem_mainjob==1) & (isco_mainjob08 == 5240)
replace class16_r=16 if (selfem_mainjob==1) & (isco_mainjob08 >= 5243 & isco_mainjob08 <= 5249)
replace class16_r=16 if (selfem_mainjob==1) & (isco_mainjob08 >= 5322 & isco_mainjob08 <= 5329)
replace class16_r=16 if (selfem_mainjob==1) & (isco_mainjob08 == 5414)
replace class16_r=16 if (selfem_mainjob==1) & (isco_mainjob08 == 8322)
replace class16_r=16 if (selfem_mainjob==1) & (isco_mainjob08 >= 9100 & isco_mainjob08 <= 9129)
replace class16_r=16 if (selfem_mainjob==1) & (isco_mainjob08 >= 9400 & isco_mainjob08 <= 9520)


mvdecode class16_r, mv(-9)
label variable class16_r "Respondent's Oesch class position - 16 classes"
label define class16_r ///
1 "Large employers" ///
2 "Self-employed professionals" ///
3 "Small business owners with employees" ///
4 "Small business owners without employees" ///
5 "Technical experts" ///
6 "Technicians" ///
7 "Skilled manual" ///
8 "Low-skilled manual" ///
9 "Higher-grade managers and administrators" ///
10 "Lower-grade managers and administrators" ///
11 "Skilled clerks" ///
12 "Unskilled clerks" ///
13 "Socio-cultural professionals" ///
14 "Socio-cultural semi-professionals" ///
15 "Skilled service" ///
16 "Low-skilled service"
label value class16_r class16_r
tab class16_r

* ATTENTION: different rank order in different oesch files. 
* silc:
/*
label variable class8 class8
label define class8 ///
1 "Self-employed professionals and large employers" ///
2 "Small business owners" ///
3 "(Associate) managers and administrators" ///
4 "Office clerks" ///
5 "Technical professionals and technicians" ///
6 "Production workers" ///
7 "Socio-cultural (semi-)professionals" ///
8 "Service workers"
*/

recode class16_r (1 2=1)(3 4=2)(5 6=3)(7 8=4)(9 10=5)(11 12=6)(13 14=7)(15 16=8), gen(class8_r)
label variable class8_r "Respondent's Oesch class position - 8 classes"
label define class8_r ///
1 "Self-employed professionals and large employers" ///
2 "Small business owners" ///
3 "Technical (semi-)professionals" ///
4 "Production workers" ///
5 "(Associate) managers" ///
6 "Clerks" ///
7 "Socio-cultural (semi-)professionals" ///
8 "Service workers"
label value class8_r class8_r
tab class8_r

gen class8 = class8_r
recode class8 (3=5) (5=3) (4=6) (6=4)

label variable class8 class8
label define class8 ///
1 "Self-employed professionals and large employers" ///
2 "Small business owners" ///
3 "(Associate) managers and administrators" ///
4 "Office clerks" ///
5 "Technical professionals and technicians" ///
6 "Production workers" ///
7 "Socio-cultural (semi-)professionals" ///
8 "Service workers"
label values class8 class8

tab class8*

drop class8_r 

* Generate various baseline groups
* allows merging with SILC data

gen young=.
replace young=1 if age<40
replace young=0 if age>39

label define young 0 "old" 1 "young"
label values young young

gen female = gndr-1

label define female 0 "male" 1 "female"
label values female female

gen class8short = class8
label variable class8short class8short
label define class8short ///
1 "Self-emp prof/employers" ///
2 "Small business owners" ///
3 "Managers/Admin" ///
4 "Office clerks" ///
5 "(Prof) Technicians" ///
6 "Production workers" ///
7 "Socio-cult spec" ///
8 "Service workers"

label values class8short class8short

egen group = group(class8short young female)

egen lab = concat(young female class8short), decode p(" ")
* ssc install labutil
labmask group, val(lab)
drop lab class8short

*******************************************************************************
* do exactly the same for partners
*******************************************************************************

* use info on gender, isco and age of other household members


* Oesch groups for partners

**** Recode occupation variable (isco88 com 4-digit) for partner


recode iscocop (66666 77777 88888 99999=-9), copyrest gen(isco_mainjob88_partner)
label variable isco_mainjob88_partner "Current occupation of respondent's partner - isco88 4-digit"

**** Recode occupation variable (isco08 com 4-digit) for partner


recode isco08p (missing=-9), copyrest gen(isco_mainjob08_partner)
label variable isco_mainjob08_partner "Current occupation of partner - isco08 4-digit"

**** Recode employment status for partner


recode emprelp (missing=9), copyrest gen(emplrel_p)
label define emplrel_p ///
1 "Employee" ///
2 "Self-employed" ///
3 "Working for own family business" ///
9 "Missing"
label value emplrel_p emplrel_p
tab emplrel_p

tab emplnop

recode emplnop (0=0)(1/9=1)(10/10000=2)(missing=0), gen(emplno_p)
label define emplno_p ///
0 "0 employees" ///
1 "1-9 employees" ///
2 "10+ employees"
label value emplno_p emplno_p
tab emplno_p

gen selfem_mainjob_partner=.
replace selfem_mainjob_partner=1 if emplrel_p==1 | emplrel_p==9
replace selfem_mainjob_partner=2 if emplrel_p==2 & emplno_p==0
replace selfem_mainjob_partner=2 if emplrel_p==3
replace selfem_mainjob_partner=3 if emplrel_p==2 & emplno_p==1
replace selfem_mainjob_partner=4 if emplrel_p==2 & emplno_p==2
label variable selfem_mainjob_partner "Employment status for partner"
label define selfem_mainjob_partner ///
1 "Not self-employed" ///
2 "Self-empl without employees" ///
3 "Self-empl with 1-9 employees" ///
4 "Self-empl with 10 or more"
label value selfem_mainjob_partner selfem_mainjob_partner
tab selfem_mainjob_partner


*************************************************
* Create Oesch class schema for respondents
*************************************************

gen class16_p = -9.

* Large employers (1)

replace class16_p=1 if selfem_mainjob_partner==4
* only available up to 2010

* ISCO 88



* Self-employed professionals (2)

replace class16_p=2 if (selfem_mainjob_partner==2 | selfem_mainjob_partner==3) & (isco_mainjob88_partner >= 2000 & isco_mainjob88_partner <= 2229) 
replace class16_p=2 if (selfem_mainjob_partner==2 | selfem_mainjob_partner==3) & (isco_mainjob88_partner >= 2300 & isco_mainjob88_partner <= 2470)

* Small business owners with employees (3)

replace class16_p=3 if (selfem_mainjob_partner==3) & (isco_mainjob88_partner >= 1000 & isco_mainjob88_partner <= 1999)
replace class16_p=3 if (selfem_mainjob_partner==3) & (isco_mainjob88_partner >= 3000 & isco_mainjob88_partner <= 9333)
replace class16_p=3 if (selfem_mainjob_partner==3) & (isco_mainjob88_partner == 2230)

* Small business owners without employees (4)

replace class16_p=4 if (selfem_mainjob_partner==2) & (isco_mainjob88_partner >= 1000 & isco_mainjob88_partner <= 1999)
replace class16_p=4 if (selfem_mainjob_partner==2) & (isco_mainjob88_partner >= 3000 & isco_mainjob88_partner <= 9333)
replace class16_p=4 if (selfem_mainjob_partner==2) & (isco_mainjob88_partner == 2230)

* Technical experts (5)

replace class16_p=5 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 2100 & isco_mainjob88_partner <= 2213)

* Technicians (6)

replace class16_p=6 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 3100 & isco_mainjob88_partner <= 3152)
replace class16_p=6 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 3210 & isco_mainjob88_partner <= 3213)
replace class16_p=6 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner == 3434)

* Skilled manual (7)

replace class16_p=7 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 6000 & isco_mainjob88_partner <= 7442)
replace class16_p=7 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 8310 & isco_mainjob88_partner <= 8312)
replace class16_p=7 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 8324 & isco_mainjob88_partner <= 8330)
replace class16_p=7 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 8332 & isco_mainjob88_partner <= 8340)

* Low-skilled manual (8)

replace class16_p=8 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 8000 & isco_mainjob88_partner <= 8300)
replace class16_p=8 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 8320 & isco_mainjob88_partner <= 8321)
replace class16_p=8 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner == 8331)
replace class16_p=8 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 9153 & isco_mainjob88_partner <= 9333)

* Higher-grade managers and administrators (9)

replace class16_p=9 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 1000 & isco_mainjob88_partner <= 1239)
replace class16_p=9 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 2400 & isco_mainjob88_partner <= 2429)
replace class16_p=9 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner == 2441)
replace class16_p=9 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner == 2470)

* Lower-grade managers and administrators (10)

replace class16_p=10 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 1300 & isco_mainjob88_partner <= 1319)
replace class16_p=10 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 3400 & isco_mainjob88_partner <= 3433)
replace class16_p=10 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 3440 & isco_mainjob88_partner <= 3450)

* Skilled clerks (11)

replace class16_p=11 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 4000 & isco_mainjob88_partner <= 4112)
replace class16_p=11 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 4114 & isco_mainjob88_partner <= 4210)
replace class16_p=11 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 4212 & isco_mainjob88_partner <= 4222)

* Unskilled clerks (12)

replace class16_p=12 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner == 4113)
replace class16_p=12 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner == 4211)
replace class16_p=12 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner == 4223)

* Socio-cultural professionals (13)

replace class16_p=13 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 2220 &  isco_mainjob88_partner <= 2229)
replace class16_p=13 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 2300 &  isco_mainjob88_partner <= 2320)
replace class16_p=13 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 2340 &  isco_mainjob88_partner <= 2359)
replace class16_p=13 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 2430 &  isco_mainjob88_partner <= 2440)
replace class16_p=13 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 2442 &  isco_mainjob88_partner <= 2443)
replace class16_p=13 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner == 2445)
replace class16_p=13 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner == 2451)
replace class16_p=13 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner == 2460)

* Socio-cultural semi-professionals (14)

replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner == 2230)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 2330 & isco_mainjob88_partner <= 2332)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner == 2444)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 2446 & isco_mainjob88_partner <= 2450)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 2452 & isco_mainjob88_partner <= 2455)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner == 3200)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 3220 & isco_mainjob88_partner <= 3224)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner == 3226)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 3229 & isco_mainjob88_partner <= 3340)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 3460 & isco_mainjob88_partner <= 3472)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner == 3480)

* Skilled service (15)

replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner == 3225)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 3227 & isco_mainjob88_partner <= 3228)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 3473 & isco_mainjob88_partner <= 3475)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 5000 & isco_mainjob88_partner <= 5113)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner == 5122)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 5131 & isco_mainjob88_partner <= 5132)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 5140 & isco_mainjob88_partner <= 5141)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner == 5143)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 5160 & isco_mainjob88_partner <= 5220)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner == 8323)

* Low-skilled service (16)

replace class16_p=16 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 5120 & isco_mainjob88_partner <= 5121)
replace class16_p=16 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 5123 & isco_mainjob88_partner <= 5130)
replace class16_p=16 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 5133 & isco_mainjob88_partner <= 5139)
replace class16_p=16 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner == 5142)
replace class16_p=16 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner == 5149)
replace class16_p=16 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner == 5230)
replace class16_p=16 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner == 8322)
replace class16_p=16 if (selfem_mainjob_partner==1) & (isco_mainjob88_partner >= 9100 &  isco_mainjob88_partner <= 9152)

* Self-employed professionals (2)

replace class16_p=2 if (selfem_mainjob_partner==2 | selfem_mainjob_partner==3) & (isco_mainjob08_partner >= 2000 & isco_mainjob08_partner <= 2162) 
replace class16_p=2 if (selfem_mainjob_partner==2 | selfem_mainjob_partner==3) & (isco_mainjob08_partner >= 2164 & isco_mainjob08_partner <= 2165) 
replace class16_p=2 if (selfem_mainjob_partner==2 | selfem_mainjob_partner==3) & (isco_mainjob08_partner >= 2200 & isco_mainjob08_partner <= 2212) 
replace class16_p=2 if (selfem_mainjob_partner==2 | selfem_mainjob_partner==3) & (isco_mainjob08_partner == 2250)
replace class16_p=2 if (selfem_mainjob_partner==2 | selfem_mainjob_partner==3) & (isco_mainjob08_partner >= 2261 & isco_mainjob08_partner <= 2262)
replace class16_p=2 if (selfem_mainjob_partner==2 | selfem_mainjob_partner==3) & (isco_mainjob08_partner >= 2300 & isco_mainjob08_partner <= 2330)
replace class16_p=2 if (selfem_mainjob_partner==2 | selfem_mainjob_partner==3) & (isco_mainjob08_partner >= 2350 & isco_mainjob08_partner <= 2352)
replace class16_p=2 if (selfem_mainjob_partner==2 | selfem_mainjob_partner==3) & (isco_mainjob08_partner >= 2359 & isco_mainjob08_partner <= 2432)
replace class16_p=2 if (selfem_mainjob_partner==2 | selfem_mainjob_partner==3) & (isco_mainjob08_partner >= 2500 & isco_mainjob08_partner <= 2619)
replace class16_p=2 if (selfem_mainjob_partner==2 | selfem_mainjob_partner==3) & (isco_mainjob08_partner == 2621)
replace class16_p=2 if (selfem_mainjob_partner==2 | selfem_mainjob_partner==3) & (isco_mainjob08_partner >= 2630 & isco_mainjob08_partner <= 2634)
replace class16_p=2 if (selfem_mainjob_partner==2 | selfem_mainjob_partner==3) & (isco_mainjob08_partner >= 2636 & isco_mainjob08_partner <= 2640)
replace class16_p=2 if (selfem_mainjob_partner==2 | selfem_mainjob_partner==3) & (isco_mainjob08_partner >= 2642 & isco_mainjob08_partner <= 2643)



* Small business owners with employees (3)

replace class16_p=3 if (selfem_mainjob_partner==3) & (isco_mainjob08_partner >= 1000 & isco_mainjob08_partner <= 1439)
replace class16_p=3 if (selfem_mainjob_partner==3) & (isco_mainjob08_partner == 2163)
replace class16_p=3 if (selfem_mainjob_partner==3) & (isco_mainjob08_partner == 2166)
replace class16_p=3 if (selfem_mainjob_partner==3) & (isco_mainjob08_partner >= 2220 & isco_mainjob08_partner <= 2240)
replace class16_p=3 if (selfem_mainjob_partner==3) & (isco_mainjob08_partner == 2260)
replace class16_p=3 if (selfem_mainjob_partner==3) & (isco_mainjob08_partner >= 2263 & isco_mainjob08_partner <= 2269)
replace class16_p=3 if (selfem_mainjob_partner==3) & (isco_mainjob08_partner >= 2340 & isco_mainjob08_partner <= 2342)
replace class16_p=3 if (selfem_mainjob_partner==3) & (isco_mainjob08_partner >= 2353 & isco_mainjob08_partner <= 2356)
replace class16_p=3 if (selfem_mainjob_partner==3) & (isco_mainjob08_partner >= 2433 & isco_mainjob08_partner <= 2434)
replace class16_p=3 if (selfem_mainjob_partner==3) & (isco_mainjob08_partner == 2620)
replace class16_p=3 if (selfem_mainjob_partner==3) & (isco_mainjob08_partner == 2622)
replace class16_p=3 if (selfem_mainjob_partner==3) & (isco_mainjob08_partner == 2635)
replace class16_p=3 if (selfem_mainjob_partner==3) & (isco_mainjob08_partner == 2641)
replace class16_p=3 if (selfem_mainjob_partner==3) & (isco_mainjob08_partner >= 2650 & isco_mainjob08_partner <= 2659)
replace class16_p=3 if (selfem_mainjob_partner==3) & (isco_mainjob08_partner >= 3000 & isco_mainjob08_partner <= 9629)

* Small business owners without employees (4)

replace class16_p=4 if (selfem_mainjob_partner==2) & (isco_mainjob08_partner >= 1000 & isco_mainjob08_partner <= 1439)
replace class16_p=4 if (selfem_mainjob_partner==2) & (isco_mainjob08_partner == 2163)
replace class16_p=4 if (selfem_mainjob_partner==2) & (isco_mainjob08_partner == 2166)
replace class16_p=4 if (selfem_mainjob_partner==2) & (isco_mainjob08_partner >= 2220 & isco_mainjob08_partner <= 2240)
replace class16_p=4 if (selfem_mainjob_partner==2) & (isco_mainjob08_partner == 2260)
replace class16_p=4 if (selfem_mainjob_partner==2) & (isco_mainjob08_partner >= 2263 & isco_mainjob08_partner <= 2269)
replace class16_p=4 if (selfem_mainjob_partner==2) & (isco_mainjob08_partner >= 2340 & isco_mainjob08_partner <= 2342)
replace class16_p=4 if (selfem_mainjob_partner==2) & (isco_mainjob08_partner >= 2353 & isco_mainjob08_partner <= 2356)
replace class16_p=4 if (selfem_mainjob_partner==2) & (isco_mainjob08_partner >= 2433 & isco_mainjob08_partner <= 2434)
replace class16_p=4 if (selfem_mainjob_partner==2) & (isco_mainjob08_partner == 2620)
replace class16_p=4 if (selfem_mainjob_partner==2) & (isco_mainjob08_partner == 2622)
replace class16_p=4 if (selfem_mainjob_partner==2) & (isco_mainjob08_partner == 2635)
replace class16_p=4 if (selfem_mainjob_partner==2) & (isco_mainjob08_partner == 2641)
replace class16_p=4 if (selfem_mainjob_partner==2) & (isco_mainjob08_partner >= 2650 & isco_mainjob08_partner <= 2659)
replace class16_p=4 if (selfem_mainjob_partner==2) & (isco_mainjob08_partner >= 3000 & isco_mainjob08_partner <= 9629)

* Technical experts (5)

replace class16_p=5 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 2100 & isco_mainjob08_partner <= 2162)
replace class16_p=5 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 2164 & isco_mainjob08_partner <= 2165)
replace class16_p=5 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 2500 & isco_mainjob08_partner <= 2529)

* Technicians (6)

replace class16_p=6 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 3100 & isco_mainjob08_partner <= 3155)
replace class16_p=6 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 3210 & isco_mainjob08_partner <= 3214)
replace class16_p=6 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 3252)
replace class16_p=6 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 3500 & isco_mainjob08_partner <= 3522)

* Skilled manual (7)

replace class16_p=7 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 6000 & isco_mainjob08_partner <= 7549)
replace class16_p=7 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 8310 & isco_mainjob08_partner <= 8312)
replace class16_p=7 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 8330)
replace class16_p=7 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 8332 & isco_mainjob08_partner <= 8340)
replace class16_p=7 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 8342 & isco_mainjob08_partner <= 8344)

* Low-skilled manual (8)

replace class16_p=8 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 8000 & isco_mainjob08_partner <= 8300)
replace class16_p=8 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 8320 & isco_mainjob08_partner <= 8321)
replace class16_p=8 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 8341)
replace class16_p=8 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 8350)
replace class16_p=8 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 9200 & isco_mainjob08_partner <= 9334)
replace class16_p=8 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 9600 & isco_mainjob08_partner <= 9620)
replace class16_p=8 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 9622 & isco_mainjob08_partner <= 9629)

* Higher-grade managers and administrators (9)

replace class16_p=9 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 1000 & isco_mainjob08_partner <= 1300)
replace class16_p=9 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 1320 & isco_mainjob08_partner <= 1349)
replace class16_p=9 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 2400 & isco_mainjob08_partner <= 2432)
replace class16_p=9 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 2610 & isco_mainjob08_partner <= 2619)
replace class16_p=9 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 2631)
replace class16_p=9 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 100 & isco_mainjob08_partner <= 110)

* Lower-grade managers and administrators (10)

replace class16_p=10 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 1310 & isco_mainjob08_partner <= 1312)
replace class16_p=10 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 1400 & isco_mainjob08_partner <= 1439)
replace class16_p=10 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 2433 & isco_mainjob08_partner <= 2434)
replace class16_p=10 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 3300 & isco_mainjob08_partner <= 3339)
replace class16_p=10 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 3343)
replace class16_p=10 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 3350 & isco_mainjob08_partner <= 3359)
replace class16_p=10 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 3411)
replace class16_p=10 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 5221)
replace class16_p=10 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 200 & isco_mainjob08_partner <= 210)

* Skilled clerks (11)

replace class16_p=11 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 3340 & isco_mainjob08_partner <= 3342)
replace class16_p=11 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 3344)
replace class16_p=11 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 4000 & isco_mainjob08_partner <= 4131)
replace class16_p=11 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 4200 & isco_mainjob08_partner <= 4221)
replace class16_p=11 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 4224 & isco_mainjob08_partner <= 4413)
replace class16_p=11 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 4415 & isco_mainjob08_partner <= 4419)

* Unskilled clerks (12)

replace class16_p=12 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 4132)
replace class16_p=12 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 4222)
replace class16_p=12 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 4223)
replace class16_p=12 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 5230)
replace class16_p=12 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 9621)

* Socio-cultural professionals (13)

replace class16_p=13 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 2200 &  isco_mainjob08_partner <= 2212)
replace class16_p=13 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 2250)
replace class16_p=13 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 2261 &  isco_mainjob08_partner <= 2262)
replace class16_p=13 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 2300 &  isco_mainjob08_partner <= 2330)
replace class16_p=13 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 2350 &  isco_mainjob08_partner <= 2352)
replace class16_p=13 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 2359)
replace class16_p=13 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 2600)
replace class16_p=13 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 2621)
replace class16_p=13 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 2630)
replace class16_p=13 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 2632 &  isco_mainjob08_partner <= 2634)
replace class16_p=13 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 2636 &  isco_mainjob08_partner <= 2640)
replace class16_p=13 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 2642 &  isco_mainjob08_partner <= 2643)

* Socio-cultural semi-professionals (14)

replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 2163)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 2166)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 2220 & isco_mainjob08_partner <= 2240)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 2260)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 2263 & isco_mainjob08_partner <= 2269)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 2340 & isco_mainjob08_partner <= 2342)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 2353 & isco_mainjob08_partner <= 2356)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 2620)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 2622)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 2635)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 2641)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 2650 & isco_mainjob08_partner <= 2659)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 3200)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 3220 & isco_mainjob08_partner <= 3230)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 3250)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 3253 & isco_mainjob08_partner <= 3257)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 3259)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 3400 & isco_mainjob08_partner <= 3410)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 3412 & isco_mainjob08_partner <= 3413)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 3430 & isco_mainjob08_partner <= 3433)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 3435)
replace class16_p=14 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 4414)

* Skilled service (15)

replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 3240)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 3251)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 3258)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 3420 & isco_mainjob08_partner <= 3423)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 3434)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 5000 & isco_mainjob08_partner <= 5120)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 5140 & isco_mainjob08_partner <= 5142)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 5163)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 5165)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 5200)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 5220)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 5222 & isco_mainjob08_partner <= 5223)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 5241 & isco_mainjob08_partner <= 5242)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 5300 & isco_mainjob08_partner <= 5321)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 5400 & isco_mainjob08_partner <= 5413)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 5419)
replace class16_p=15 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 8331)

* Low-skilled service (16)

replace class16_p=16 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 5130 & isco_mainjob08_partner <= 5132)
replace class16_p=16 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 5150 & isco_mainjob08_partner <= 5162)
replace class16_p=16 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 5164)
replace class16_p=16 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 5169)
replace class16_p=16 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 5210 & isco_mainjob08_partner <= 5212)
replace class16_p=16 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 5240)
replace class16_p=16 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 5243 & isco_mainjob08_partner <= 5249)
replace class16_p=16 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 5322 & isco_mainjob08_partner <= 5329)
replace class16_p=16 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 5414)
replace class16_p=16 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner == 8322)
replace class16_p=16 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 9100 & isco_mainjob08_partner <= 9129)
replace class16_p=16 if (selfem_mainjob_partner==1) & (isco_mainjob08_partner >= 9400 & isco_mainjob08_partner <= 9520)


mvdecode class16_p, mv(-9)
label variable class16_p "Partner's Oesch class position - 16 classes"
label define class16_p ///
1 "Large employers" ///
2 "Self-employed professionals" ///
3 "Small business owners with employees" ///
4 "Small business owners without employees" ///
5 "Technical experts" ///
6 "Technicians" ///
7 "Skilled manual" ///
8 "Low-skilled manual" ///
9 "Higher-grade managers and administrators" ///
10 "Lower-grade managers and administrators" ///
11 "Skilled clerks" ///
12 "Unskilled clerks" ///
13 "Socio-cultural professionals" ///
14 "Socio-cultural semi-professionals" ///
15 "Skilled service" ///
16 "Low-skilled service"
label value class16_p class16_p
tab class16_p

* ATTENTION: different rank order in different oesch files. 
* silc:
/*
label variable class8 class8
label define class8 ///
1 "Self-employed professionals and large employers" ///
2 "Small business owners" ///
3 "(Associate) managers and administrators" ///
4 "Office clerks" ///
5 "Technical professionals and technicians" ///
6 "Production workers" ///
7 "Socio-cultural (semi-)professionals" ///
8 "Service workers"
*/

recode class16_p (1 2=1)(3 4=2)(5 6=3)(7 8=4)(9 10=5)(11 12=6)(13 14=7)(15 16=8), gen(class8_p)
label variable class8_p "Respondent's Oesch class position - 8 classes"
label define class8_p ///
1 "Self-employed professionals and large employers" ///
2 "Small business owners" ///
3 "Technical (semi-)professionals" ///
4 "Production workers" ///
5 "(Associate) managers" ///
6 "Clerks" ///
7 "Socio-cultural (semi-)professionals" ///
8 "Service workers"
label value class8_p class8_p
tab class8_p

gen pclass8 = class8_p
recode pclass8 (3=5) (5=3) (4=6) (6=4)

label variable pclass8 pclass8
label define pclass8 ///
1 "Self-employed professionals and large employers" ///
2 "Small business owners" ///
3 "(Associate) managers and administrators" ///
4 "Office clerks" ///
5 "Technical professionals and technicians" ///
6 "Production workers" ///
7 "Socio-cultural (semi-)professionals" ///
8 "Service workers"
label values pclass8 pclass8

drop class8_p

gen pclass8short = pclass8
label variable pclass8short pclass8short
label define pclass8short ///
1 "Self-emp prof/employers" ///
2 "Small business owners" ///
3 "Managers/Admin" ///
4 "Office clerks" ///
5 "(Prof) Technicians" ///
6 "Production workers" ///
7 "Socio-cult spec" ///
8 "Service workers"

label values pclass8short pclass8short

gen page = .
forval i = 2/14 {
replace page = year-yrbrn`i' if rship`i'==1&year==2002
}
forval i = 2/14 {
replace page = year-yrbrn`i' if rshipa`i'==1
}

* some miscoding

replace page=. if page<18
replace page=. if agea-page>50 & age!=. & page!=.
replace page=. if page-agea>50 & age!=. & page!=.

gen pyoung = (page<40)
replace pyoung=. if page==.

gen pfemale = .
forval i = 2/14 {
replace pfemale = gndr`i'-1 if rship`i'==1&year==2002
}
forval i = 2/14 {
replace pfemale = gndr`i'-1 if rshipa`i'==1
}
replace pfemale=. if pfemale<0 | pfemale>1

label define pyoung 0 "old" 1 "young"
label values pyoung pyoung

label define pfemale 0 "male" 1 "female"
label values pfemale pfemale

egen pgroup = group(pclass8short pyoung pfemale)

egen plab = concat(pyoung pfemale pclass8short), decode p(" ")
* ssc install labutil
labmask pgroup, val(plab)
drop plab pclass8short

* Generate ISCO baeline groups

gen isco88_2d = real(substr(string(iscoco), 1, 2))
gen isco08_2d = real(substr(string(isco08), 1, 2))

gen isco88_1d = real(substr(string(iscoco, "%5.0g"), 1, 1))
gen isco08_1d = real(substr(string(isco08, "%5.0g"), 1, 1))

egen isco88group = group(isco88_1d young female)

egen labisco88 = concat(young female isco88_1d), decode p(" ")
labmask isco88group, val(labisco88)

egen isco08group = group(isco08_1d young female)

egen labisco08 = concat(young female isco08_1d), decode p(" ")
labmask isco08group, val(labisco08)

gen pisco88_2d = real(substr(string(iscocop), 1, 2))
gen pisco08_2d = real(substr(string(isco08p), 1, 2))

gen pisco88_1d = real(substr(string(iscocop, "%5.0g"), 1, 1))
gen pisco08_1d = real(substr(string(isco08p, "%5.0g"), 1, 1))

egen pisco88group = group(pisco88_1d pyoung pfemale)

egen labpisco88 = concat(pyoung pfemale pisco88_1d), decode p(" ")
labmask pisco88group, val(labpisco88)

egen pisco08group = group(pisco08_1d pyoung pfemale)

egen labpisco08 = concat(pyoung pfemale pisco08_1d), decode p(" ")
labmask pisco08group, val(labpisco08)

* Generate ISCO x gender baseline group


egen isco88female = group(isco88_1d female)

egen labisco88female = concat(female isco88_1d), decode p(" ")
labmask isco88female, val(labisco88female)

egen isco08female = group(isco08_1d female)

egen labisco08female = concat(female isco08_1d), decode p(" ")
labmask isco08female, val(labisco08female)

egen pisco88female = group(pisco88_1d pfemale)

egen labpisco88female = concat(pfemale pisco88_1d), decode p(" ")
labmask pisco88female, val(labpisco88female)

egen pisco08female = group(pisco08_1d pfemale)

egen labpisco08female = concat(pfemale pisco08_1d), decode p(" ")
labmask pisco08female, val(labpisco08female)


***************************************
* MERGING 
***************************************

* Merge ESS data with occupational risk from EU-SILC for various baseline groups

* respondent

foreach var of varlist group isco88group isco08group isco88_2d isco08_2d isco88_1d isco08_1d  isco88female isco08female {

merge m:m cntry year `var' using "$datpath/20201008_unemprisk_`var'.dta", gen(merge_`var')
drop if merge_`var'==2
}

* partner

foreach var of varlist pgroup pisco88group pisco08group pisco88_2d pisco08_2d pisco88_1d pisco08_1d pisco88female pisco08female {
merge m:m cntry year `var' using "$datpath/20201008_punemprisk_`var'.dta", gen(merge_`var')
drop if merge_`var'==2
}

label variable unemprisk "Share of unemp per group32 (oesch8xagexsex), share of class8 if ngroup<50"


* create complete iscos (combined isco88 and isco08)

gen unemprisk_isco = unemprisk_isco88 if year<2012
replace unemprisk_isco = unemprisk_isco08 if year>2010

label variable unemprisk_isco "Share of unemp per group36 (isco1dxagexsex), share of isco1d if ngroup<50"


gen punemprisk_isco = punemprisk_isco88 if year<2012
replace punemprisk_isco = punemprisk_isco08 if year>2010

label variable punemprisk_isco "Share of unemp per partner's group36 (isco1dxagexsex), share of isco1d if ngroup<50"


gen unemp_isco_1d = unempisco88_1d if year<2012
replace unemp_isco_1d = unempisco08_1d if year>2010

label variable unemp_isco_1d "Occupational unemployment risk by ISCO-1d"


gen unemp_isco_2d = unempisco88_2d if year<2012
replace unemp_isco_2d = unempisco08_2d if year>2010

label variable unemp_isco_2d "Occupational unemployment risk by ISCO-2d"

gen unemp_isco_2d_robust = unempisco88_2d_robust if year<2012
replace unemp_isco_2d_robust = unempisco08_2d_robust if year>2010

label variable unemp_isco_2d_robust "Occupational unemployment risk by ISCO-2d, replaced with 1d if n<50"

gen unemp_isco_1d_female = unempisco88female if year<2012
replace unemp_isco_1d_female = unempisco08female if year>2010

label variable unemp_isco_1d_female "Occupational unemployment risk by ISCO-1d and gender"


gen punemp_isco_1d = punempisco88_1d if year<2012
replace punemp_isco_1d = punempisco08_1d if year>2010

label variable punemp_isco_1d "Partner's occupational unemployment risk by ISCO-1d"

gen punemp_isco_2d = punempisco88_2d if year<2012
replace punemp_isco_2d = punempisco08_2d if year>2010

label variable punemp_isco_2d "Partner's occupational unemployment risk by ISCO-2d"

gen punemp_isco_2d_robust = punempisco88_2d_robust if year<2012
replace punemp_isco_2d_robust = punempisco08_2d_robust if year>2010

label variable punemp_isco_2d_robust "Partner's occupational unemployment risk by ISCO-2d, , replaced with 1d if n<50"

gen punemp_isco_1d_female = punempisco88female if year<2012
replace punemp_isco_1d_female = punempisco08female if year>2010

label variable punemp_isco_1d_female "Partner's occupational unemployment risk by ISCO-1d and gender"


* SAVE FILE

save "$final/riskradright.dta", replace

